from Inspect.models import Departments
from Inspect import db
import time

class departmentCountroller:
    def addDepartment(**kwargs):
        departmentName = kwargs["departmentName"]
        obj = Departments(departmentName=departmentName)
        db.session.add(obj)
        db.session.flush()
        db.session.commit()
        print(obj.id)
        return {
            "code": "200",
            "data": obj.to_json()
        }

    def getDepartmentList(**kwargs):
        obj = Departments.query.all()
        db.session.close()
        t = []
        for a in obj:
            print(a.to_json())
            t.append(a.to_json())
        return t
